
cmake_minimum_required(VERSION 3.14)
#设置工程名字
project(fcbwidgets LANGUAGES CXX)
project(fcbwidgets VERSION 1.0)

set(CMAKE_AUTOUIC ON) #自动用qt的uic程序处理.ui文件
set(CMAKE_AUTOMOC ON) #自动用QT的moc程序处理
set(CMAKE_AUTORCC ON) #自动用qt的qcc程序处理资源文件

#设置支持c17
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

#为每个模块提供*.cmake文件搜索路径,记得在环境变量中配置QT5的目录。QT5_HOME
set(CMAKE_PREFIX_PATH  $ENV{QT5_HOME})
set(QT_VERSION_MAJOR 5)
set(CMAKE_PREFIX_PATH /Users/hzp/hzpdev/gitee/qt/qt-everywhere-src-5.15.9/outDir)

set(Qt5_DIR "${CMAKE_PREFIX_PATH}/lib/cmake/Qt5")
set(Qt5Widgets_DIR "${CMAKE_PREFIX_PATH}/lib/cmake/Qt5Widgets")
#set(Qt5Network_DIR "${CMAKE_PREFIX_PATH}/lib/cmake/Qt5Network")
#set(Qt5LinguistTools_DIR "${CMAKE_PREFIX_PATH}/lib/cmake/Qt5LinguistTools")
find_package(Qt5 REQUIRED COMPONENTS Widgets)

#设置cmake的运行目录
set(PROJECT_BINARY_DIR ${PROJECT_SOURCE_DIR}/../build/fcbwidets)

#将上级目录（../下的所有文件）放入SOURCE_LIST,注意这里的目录要以cmake的运行目录为相对目录
FILE(GLOB_RECURSE source_file_list *.h *.cpp *.ui *.qrc)
set(PROJECT_SOURCES ${source_file_list} )

FOREACH(file ${source_file_list})
message(STATUS "[FIle] Found ::: ${file}")
ENDFOREACH()



#设置包含文件目录
include_directories(.)

#指定编译为静态库STATIC,要编译动态库，SHARED  ,可以同时输出静态库和动态库
add_library(fcbwidgets  STATIC   ${PROJECT_SOURCES} )
#设置编译输出的文件名 ,不用指定开始的lib,这一句也可以不写，默认就add_library的第一个参数名
set_target_properties(fcbwidgets PROPERTIES OUTPUT_NAME "fcbwidgets")
 
#将对应的库连接到目标，类似与QT的pro文件的 -l  ,这里的第一个参数是add_library的第一个参数名.
target_link_libraries(fcbwidgets PRIVATE Qt${QT_VERSION_MAJOR}::Widgets)
# target_link_libraries(fcbwidgets PRIVATE Qt${QT_VERSION_MAJOR}::Network)
# target_link_libraries(fcbwidgets PRIVATE Qt${QT_VERSION_MAJOR}::Qml)
# target_link_libraries(fcbwidgets PRIVATE Qt${QT_VERSION_MAJOR}::Quick)

#设置目录 CMAKE_BINARY_DIR为CMakeLists.txt所在目录
set(LIBRARY_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/../debug)
# ：运行cmake命令的目录，通常为${}/build
#也亦可以单独设置静态库和动态库的
# #设置静态库的目录 CMAKE_BINARY_DIR为
# set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/../../../lib)
# #设置静态库的目录 CMAKE_BINARY_DIR为
# set_target_properties(components_shared PROPERTIES RUNTIME_OUTPUT_DIRECTORY ../../../bin)

#添加编译定义 和QT的pro工程中的DEFINES += GORUN8_LIB_LIBRARY等同
target_compile_definitions(fcbwidgets PRIVATE GORUN8_LIB_LIBRARY)
